import { Component, OnInit } from '@angular/core'
import { DataService } from '@shared/services/data.service'
import { User } from '@shared/interfaces/user'
import { IBiz } from '@shared/interfaces/biz'
import { EBizLevel, EUserType } from '@shared/enums'

@Component({
  selector: 'app-user-system',
  templateUrl: './user-system.component.html',
})
export class UserSystemComponent implements OnInit {
  user: User

  bizInfo: IBiz
  bizLevel: EBizLevel
  constructor(
    private dataService: DataService,
  ) {}

  ngOnInit() {
    this.user = this.dataService.user
    console.log('user', this.user)
    this.initialRestColumns(this.user)
  }

  initialRestColumns(user: User) {
    this.bizInfo = user
    switch (user.userType) {
      case EUserType.Institution:
        this.bizLevel = EBizLevel.Agent
        break
      case EUserType.Agent:
        this.bizLevel = EBizLevel.Merchant
        break
      case EUserType.Merchant:
        this.bizLevel = EBizLevel.Store
        break
      case EUserType.Store:
        this.bizLevel = EBizLevel.Terminal
        break
      default:
        break
    }
  }
}
